#ifndef STATELABEL_H
#define STATELABEL_H

#include "../StateBase.h"
#include <functional>
#include <QObject>
#include <QLabel>

class StateLabel : public QLabel, private StateBase
{
    Q_OBJECT
public:
    StateLabel(QWidget *parent = nullptr);

    Q_PROPERTY(bool _actived READ isActived WRITE setActived USER true)
    bool isActived(){return _actived;}
    void setActived(bool actived) {
        if(_actived==actived)
            return;
        _actived = actived;
        setState("actived",actived);
        repolish();
    }

    Q_PROPERTY(bool _selected READ isSelected WRITE setSelected USER true)
    bool isSelected(){return _selected;}
    void setSelected(bool selected) {
        if(_selected==selected)
            return;
        _selected = selected;
        setState("selected",selected);
        repolish();
    }

signals:
    void sigClicked();
    void sigDblClicked();

protected:
    void mouseDoubleClickEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void leaveEvent(QEvent *event);
    void repolish();

private:
    bool _actived;
    bool _selected;
    bool _pressed;
};

#endif // STATELABEL_H
